home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_05 / allison / tdate.c < prev    next >
C/C++ Source or Header  |  1995-03-12  |  605b  |  29 lines

  1. LISTING 3 - Tests the Date type
  2. /* tdate.c */
  3. #include <stdio.h>
  4. #include "date.h"
  5.  
  6. #define DATELEN 19
  7.  
  8. main()
  9. {
  10.     Date d1 = {10,1,1951}, d2 = {3,7,1995};
  11.     char buf[DATELEN+1];
  12.     int cmp;
  13.  
  14.     printf("d1 == %s\n",date_format(&d1,buf));
  15.     printf("d2 == %s\n",date_format(&d2,buf));
  16.     cmp = date_compare(&d1,&d2);
  17.     printf("d1 %s d2\n",(cmp < 0) ? "precedes"
  18.                                   : (cmp > 0) ? "follows"
  19.                                               : "equals");
  20.     return 0;
  21. }
  22.  
  23. /* Output:
  24. d1 == October 1, 1951
  25. d2 == March 7, 1995
  26. d1 precedes d2
  27. */
  28.  
  29.